package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.mapper.WmChannelMapper;
import com.heima.wemedia.service.WmChannelService;
import com.heima.wemedia.service.WmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/v1/channel")
public class ChannelController {
	@Autowired
	private WmChannelService wmChannelService;
	//文章列表
	@GetMapping("/channels")
	public ResponseResult getChannels() {
		
		return wmChannelService.getChannels();
		// return null;
	}
	
	//新增频道
	@PostMapping("/save")
	public ResponseResult channelSave(@RequestBody WmChannel wmChannel) {
		
		return wmChannelService.channel(wmChannel);
	}
	
	//查询列表
	@PostMapping("/list")
	public ResponseResult channelList(@RequestBody ChannelDto dto) {
		return wmChannelService.channelList(dto);
	}
	
	//修改
	@PostMapping("/update")
	public ResponseResult channelUpdate(@RequestBody WmChannel wmChannel) {
		return wmChannelService.channelUpdate(wmChannel);
	}
	
	//删除
	@GetMapping("/del/{id}")
	public ResponseResult channelDelete(@PathVariable("id") Long id) {
		return wmChannelService.channelDelete(id);
	}
}
